package view.mediator.weapon.double_sword
{
	import flash.system.System;
	
	import model.weapon.WeaponModel;
	
	import org.robotlegs.mvcs.StarlingMediator;
	
	import view.component.weapon.double_sword.DoubleSwordView;
	import view.event.weapon.double_sword.DoubleSwordViewEvent;
	
	
	/**
	 * DoubleSwordView界面中介
	 * @author £iang
	 * 
	 */	
	public class DoubleSwordViewMediator extends StarlingMediator
	{
		//-----------------------------
		// variables
		//-----------------------------
		
		/** DoubleSwordView界面 */
		[Inject]
		public var doubleSwordView:DoubleSwordView;
		/** weaponModel */
		[Inject]
		public var weaponModel:WeaponModel;
		
		//-----------------------------
		// properties
		//-----------------------------
		
		//-----------------------------
		// setter&getter
		//-----------------------------
		
		//-----------------------------
		// methods
		//-----------------------------
		
		/**
		 * 注册函数 
		 * 
		 */		
		override public function onRegister():void
		{
			doubleSwordView.otherView.setText( weaponModel.weaponOtherInfoData["double_sword"] );
			addContextListener( DoubleSwordViewEvent.CHANGE_PAGE, changePageHandler );
		}
		
		//-----------------------------
		// events
		//-----------------------------
		
		/**
		 * 处理请求滚动条容器翻页时派发的消息 
		 * @param event 请求滚动条容器翻页时派发的消息 
		 * 
		 */		
		protected function changePageHandler( event:DoubleSwordViewEvent ):void
		{
			doubleSwordView.changeSCPageIndex( event.newPage );
		}
		
		//-----------------------------
		// dispose
		//-----------------------------
		
		/**
		 * 移除函数 
		 * 
		 */		
		override public function onRemove():void
		{
			removeContextListener( DoubleSwordViewEvent.CHANGE_PAGE, changePageHandler );
			doubleSwordView.mainSC.removeChild( doubleSwordView.listView, true );
			doubleSwordView.listView = null;
			doubleSwordView.mainSC.removeChild( doubleSwordView.detailView, true );
			doubleSwordView.detailView = null;
			doubleSwordView.mainSC.removeChild( doubleSwordView.searchView, true );
			doubleSwordView.searchView = null;
			doubleSwordView.mainSC.removeChild( doubleSwordView.motionView, true );
			doubleSwordView.motionView = null;
			System.gc();
			super.onRemove();
		}
		
		//-----------------------------
		// construction
		//-----------------------------
		
		/**
		 * 构造函数
		 *
		 */
		public function DoubleSwordViewMediator()
		{
			super();
		}
	}
}